package com.adcc.swingui.demo.toolbar;

import java.awt.Container;

import javax.swing.AbstractButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;

import com.adcc.swingui.base.DefaultToolBar;
import com.jidesoft.swing.AutoCompletionComboBox;

/**
 * 查找工具条  ,控件组结构，该结构最好只被创建一次，创建多次，会出现异常
 * @author charlie
 *
 */
public class FindToolBut extends DefaultToolBar {

	protected static JLabel findLab;//工具组名称
	protected static JComboBox typeBox;//类型
	protected static AutoCompletionComboBox listBox;//查询列表
	protected static AbstractButton findBut;//查询按钮

	private JLabel lab;
	public FindToolBut(Container container) {
		super(container);
	}

	@Override
	protected JComponent build() {
		lab = new JLabel("查找类型");
		
		//控件组赋值
		findLab = lab;
		return lab;
	}

	@Override
	protected void addMouseListener() {
	}

	@Override
	protected void i18n() {
		lab.setText("查找类型");
	}
	
	/**
	 * 查找类型
	 * @author charlie
	 *
	 */
	public static class FindType extends DefaultToolBar {

		private JComboBox box;

		public FindType(Container container) {
			super(container);
		}

		@Override
		protected JComponent build() {
			box = createComboBox("飞机");
			box.setEditable(false);
			box.addItem("机场");
			box.addItem("航路");
			//控件组赋值
			typeBox  = box;
			return box;
		}

		@Override
		protected void addMouseListener() {
			//类型切换，替换后面下拉框中的数据
		}

		@Override
		protected void i18n() {
		}
	}
	
	/**
	 * 查找列表框
	 * @author charlie
	 *
	 */
	public static class FindComboBox extends DefaultToolBar {
		private AutoCompletionComboBox box;

		public FindComboBox(Container container) {
			super(container);
		}

		@Override
		protected JComponent build() {
			box = new AutoCompletionComboBox();
			box.setStrict(false);
			box.setSelectedIndex(-1);
			box.addItem("B-5533 MH370");
			box.addItem("B-6533 MH17");
			box.addItem("C-6533 SC2592");
			
			//控件组赋值
			listBox  = box;
			return box;
		}

		@Override
		protected void addMouseListener() {
		}

		@Override
		protected void i18n() {
		}
	}
	
	/**
	 * 查找按钮
	 * @author charlie
	 *
	 */
	public static class FindBut extends DefaultToolBar {
		private AbstractButton but;

		public FindBut(Container container) {
			super(container);
		}

		@Override
		protected JComponent build() {
			but = createButton("查找");//这个可以用一个图片按钮
			
			
			//控件组赋值
			findBut  = but;
			return but;
		}

		@Override
		protected void addMouseListener() {
			//找出类型，和查找内容，在地图上进行定位
		}

		@Override
		protected void i18n() {
		}
	}
}
